package com.maiji.cloud.controller.community;


import com.maiji.cloud.controller.BaseController;
import com.maiji.cloud.entities.community.ComMsgTransmitRule;
import com.maiji.cloud.request.BaseInputDto;
import com.maiji.cloud.request.IdInputDto;
import com.maiji.cloud.request.community.ComPubComInputDto;
import com.maiji.cloud.request.community.ComRecsInputDto;
import com.maiji.cloud.request.community.ComSearchInputDto;
import com.maiji.cloud.response.BaseOutPutDto;
import com.maiji.cloud.response.BaseResDto;
import com.maiji.cloud.response.Status;
import com.maiji.cloud.response.community.ComDetailOutputDto;
import com.maiji.cloud.response.community.ComRecsOutputDto;
import com.maiji.cloud.response.community.CommunityStatisticsOutputDto;
import com.maiji.cloud.response.shopingmall.FinancialDetailsResData;
import com.maiji.cloud.utils.Unlogin;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/community")
@Api(tags = {"社区"})
public class CommunityController extends BaseController {

    @PostMapping ("/publish")
    @ApiOperation("发布动态")
    public BaseOutPutDto<ComRecsOutputDto> publish(@RequestBody BaseInputDto<ComPubComInputDto> inputDto, @RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/publish", inputDto, BaseOutPutDto.class);
    }

    @Unlogin
    @PostMapping("/detailMsg")
    @ApiOperation("动态详细")
    public BaseOutPutDto<ComDetailOutputDto> detailMsg(@RequestBody BaseInputDto<IdInputDto> inputDto, @RequestHeader(value = "maijiToken" , required =false)String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/detailMsg", inputDto, BaseOutPutDto.class);
    }

    @Unlogin
    @PostMapping("/caseList")
    @ApiOperation("案例列表")
    public BaseOutPutDto<List<ComRecsOutputDto>> caseList(@RequestBody BaseInputDto<ComRecsInputDto> inputDto, @RequestHeader(value="maijiToken",required =false)String maijiToken){

        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/caseList", inputDto, BaseOutPutDto.class);
    }

    @Unlogin
    @PostMapping("/recommends")
    @ApiOperation("推荐列表 用户发表的动态非第一时间被浏览")
    public BaseOutPutDto<List<ComRecsOutputDto>> recommends(@RequestBody BaseInputDto<ComRecsInputDto> inputDto, @RequestHeader(value = "maijiToken",required =false)String maijiToken){


        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/recommends", inputDto, BaseOutPutDto.class);
    }
    @PostMapping("/commonMsgs")
    @ApiOperation("普通动态列表 用户发表的动态可以第一时间被浏览")
    @Unlogin
    public BaseOutPutDto<List<ComRecsOutputDto>> commonMsgs(@RequestBody BaseInputDto<ComRecsInputDto> inputDto,@RequestHeader(value = "maijiToken",required =false)String maijiToken){

        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/commonMsgs", inputDto, BaseOutPutDto.class);
    }

    @Unlogin
    @PostMapping("/msgList")
    @ApiOperation("社区通用列表查询")
    public BaseOutPutDto<List<ComRecsOutputDto>> msgList(@RequestBody BaseInputDto<ComRecsInputDto> inputDto,@RequestHeader(value = "maijiToken",required =false)String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/msgList", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/focusersBlogList")
    @ApiOperation("关注动态列表")
    public BaseOutPutDto<List<ComRecsOutputDto>> focusersBlogList(@RequestBody BaseInputDto<ComRecsInputDto> inputDto, @RequestHeader("maijiToken")String maijiToken){

        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/focusersBlogList", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/mineBlogList")
    @ApiOperation("我的动态列表")
    public BaseOutPutDto<List<ComRecsOutputDto>> mineBlogList(@RequestBody BaseInputDto inputDto,@RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/mineBlogList", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/userBlogList")
    @ApiOperation("用户动态列表")
    public BaseOutPutDto<List<ComRecsOutputDto>> userBlogList(@RequestBody BaseInputDto<IdInputDto> inputDto,@RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/userBlogList", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/userHotList")
    @ApiOperation("用户被推荐过的动态列表 priority 优先级>=1")
    public BaseOutPutDto<List<ComRecsOutputDto>> userHotList(@RequestBody BaseInputDto<IdInputDto> inputDto,@RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/userHotList", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/topList")
    @ApiOperation("社区置顶列表")
    public BaseOutPutDto<List<ComRecsOutputDto>> topList(@RequestBody BaseInputDto inputDto,@RequestHeader(value = "maijiToken",required =false)String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/topList", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/integralList")
    @ApiOperation("可转发得积分列表")
    @Unlogin
    public BaseOutPutDto<List<ComRecsOutputDto>> integralList(@RequestBody BaseInputDto<ComRecsInputDto> inputDto,@RequestHeader(value = "maijiToken",required =false)String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/integralList", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/unionMsgList")
    @ApiOperation("发现 、 精选 、 积分通用接口")
    @Unlogin
    public BaseOutPutDto<List<ComRecsOutputDto>> unionMsgList(@RequestBody BaseInputDto<ComRecsInputDto> inputDto,@RequestHeader(value = "maijiToken",required =false)String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/unionMsgList", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/shareSuc")
    @ApiOperation("分享成功调用")
    public BaseOutPutDto<FinancialDetailsResData> shareSuc(@RequestBody BaseInputDto<IdInputDto> inputDto, @RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/shareSuc", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/searchMsg")
    @ApiOperation("搜索动态")
    public BaseOutPutDto<List<ComRecsOutputDto>> searchMsg(@RequestBody BaseInputDto<ComSearchInputDto> inputDto, @RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/searchMsg", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/delete")
    @ApiOperation("删除动态")
    public BaseOutPutDto<String>delete(@RequestBody BaseInputDto<IdInputDto> inputDto,@RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/delete", inputDto, BaseOutPutDto.class);
    }
    
    /**
     * 根据用户ID统计用户粉丝/关注/发布的动态数量
     * @param
     * @return
     */
    @PostMapping("/communityStatisticsQuantity")
    @ApiOperation("根据用户ID统计用户粉丝/关注/发布的动态数量")
    public BaseOutPutDto<CommunityStatisticsOutputDto> communityStatisticsQuantity(@RequestBody BaseInputDto<String> inputDto,@RequestHeader("maijiToken")String maijiToken){
    	  return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/communityStatisticsQuantity", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/findMsgsByActName")
    @ApiOperation("根据活动搜索动态列表 ， 置顶独立")
    @Unlogin
    public BaseOutPutDto<List<ComRecsOutputDto>> findMsgsByActName(@RequestBody BaseInputDto<ComRecsInputDto> inputDto,@RequestHeader(value = "maijiToken",required =false)String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/findMsgsByActName", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/homePageList")
    @ApiOperation("首页列表")
    @Unlogin
    public BaseOutPutDto<List<ComRecsOutputDto>> homePageList(@RequestBody BaseInputDto<ComRecsInputDto> inputDto,@RequestHeader(value = "maijiToken",required =false)String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/homePageList", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/updMsgTransmitRule")
    @ApiOperation("更新转发得积分基本规则")
    @Unlogin
    public BaseOutPutDto updMsgTransmitRule (@RequestBody BaseInputDto<ComMsgTransmitRule> inputDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/updMsgTransmitRule", inputDto, BaseOutPutDto.class);
    }

}
